<?php
// +----------------------------------------------------------------------
// | 用户模型
// +----------------------------------------------------------------------
// | Author: myh
// +----------------------------------------------------------------------
namespace app\common\model;

class UserModel extends BaseModel
{   
    protected $table = 'ds_user';

    public static $status = [0=>'禁用',1=>'正常'];

    public static $sex = [0=>'未知',1=>'男',2=>'女'];

    public function searchAccountAttr($query, $value, $data)
    {
        $query->where('account', $value);
    }

    public function searchMobileAttr($query, $value, $data)
    {
        $query->where('mobile', $value);
    }

    public function searchStatusAttr($query, $value, $data)
    {
        $query->where('status', $value);
    }

    public function searchLevelAttr($query, $value, $data)
    {
        $query->where('level', $value);
    }

    public function userLevel()
    {
        return $this->hasOne(UserLevelModel::class, 'id')->bind(['level_name','growth_value']);
    }

}
